package mj.scott.back.exam.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import mj.scott.back.base.response.JsonResult;
import mj.scott.back.exam.pojo.dto.ExamQuery;
import mj.scott.back.exam.pojo.dto.ExamSaveParam;
import mj.scott.back.exam.pojo.vo.ExamVO;
import mj.scott.back.exam.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@Tag(name = "考试模块")
@Slf4j
@RestController
@RequestMapping("/v1/exam/")
public class ExamController {
    @Autowired
    ExamService examService;
    /**
     * 查询考试列表
     */
    @GetMapping("select")
    @Operation(summary = "查询考试列表")
    @ApiOperationSupport(order = 10)
    public JsonResult selectExam(ExamQuery query){
        log.debug("【控制层】【查询考试列表】{}",query);
        List<ExamVO> vo = examService.select(query);
        System.currentTimeMillis();
        return JsonResult.ok(vo);
    }
    /**
     * 保存考试
     */
    @PostMapping("save")
    @Operation(summary = "保存考试")
    @ApiOperationSupport(order = 20)
    public JsonResult saveExam(ExamSaveParam param){
        log.debug("【控制层】【保存考试】{}",param);
        examService.saveExam(param);
        return JsonResult.ok();
    }

    /**
     * 删除考试
     */
    @GetMapping("delete")
    @Operation(summary = "删除考试")
    @ApiOperationSupport(order = 30)
    public JsonResult deleteExam(Long examId){
        log.debug("【控制层】【删除考试】{}",examId);
        examService.deleteExam(examId);
        return JsonResult.ok();
    }
}
